home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / comms / other / novia / src / novia_filesystem.c < prev    next >
C/C++ Source or Header  |  1999-12-06  |  2KB  |  101 lines

  1. #include <string.h>
  2. #include <pragma/exec_lib.h>
  3. #include <pragma/noviasys_lib.h>
  4. #include <novia/novia_portdata.h>
  5. #include <novia/novia_dos.h>
  6. #include <exec/tasks.h>
  7.  
  8. extern MainPortConfig *mainportconfig;
  9.  
  10. void adddir_atroot(char *name)
  11. {
  12.     struct Directory *dir;
  13.     if ((dir = AllocVec(sizeof(Directory), MEMF_ANY | MEMF_CLEAR)))
  14.     {
  15.         BPTR fh = NULL;
  16. /*        if (!(fh = CreateDir(name)))
  17.         {
  18.             fh = Lock(name,SHARED_LOCK);
  19.         }
  20.         if (fh)*/
  21.         {
  22. //            UnLock(fh);
  23.             strncpy(dir->iib.Title, name, sizeof(dir->iib.Title)-1);// copy subdir name into title
  24.             strncpy(dir->iib.Filename, name, sizeof(dir->iib.Filename)-1);
  25.  
  26.             dir->iib.Protection = (FIBF_READ | FIBF_WRITE | FIBF_EXECUTE | FIBF_DELETE);
  27.  
  28.             dir->iib.ItemType=ITEMTYPE_SUBBOARD;                        // set ItemType
  29.             dir->iib.IPNumber = mainportconfig->BaseIPCounter++ +1;
  30.             SaveMainPortConfig(mainportconfig);
  31.             dir->fh_messages    = NULL;
  32.             dir->fh_files        = NULL;
  33.             dir->fh_dirs        = NULL;
  34.             dir->fh_text        = NULL;
  35.             dir->fh_replys        = NULL;
  36.  
  37.             GetTime(&dir->iib.LastChange);                                // Get actual systemtime.
  38.             CopyMemQuick(&dir->iib.LastChange, &dir->iib.CreateDate, sizeof(Date)); // 'nd copy date to createtime
  39.  
  40.  
  41.             if ((fh = Open("novia:.dirs", MODE_READWRITE)))
  42.             {
  43.                 Seek(fh, 0, OFFSET_END);
  44.                 Write(fh, dir, sizeof(Directory));
  45.                 Close(fh);
  46.                 ioprintf("directory %s added\n",name);
  47.             }
  48.             else
  49.                 ioprintf("can't add directory entry for %s\n",name);
  50.         }
  51. /*        else
  52.             ioprintf("Can't create %s\n",name);*/
  53.         FreeVec(dir);
  54.     }
  55. }
  56.  
  57. void LowLevelCommand_addcommand()
  58. {
  59.     struct PortData *cport = (PortData *)FindTask(NULL)->tc_UserData;
  60.     if (cport)
  61.         nslib_list(cport);
  62. }
  63.  
  64. void LowLevelCommand_adddirectory()
  65. {
  66. }
  67.  
  68. void LowLevelCommand_makeroot()
  69. {
  70.     char *name="novia:sbin/helloworld";
  71.     ioprintf("name: %s %x\n",name,name);
  72.     ndos_execute(name);
  73. }
  74.  
  75. void LowLevelCommand_addlink()
  76. {
  77. }
  78.  
  79.  
  80.             
  81. void LowLevelCommand_makefs()
  82. {
  83.     DeleteFile("dirs");
  84.     adddir_atroot("bin");
  85.     adddir_atroot("sbin");
  86.     adddir_atroot("etc");
  87.     adddir_atroot("scripts");
  88.     adddir_atroot("etc");
  89.     adddir_atroot("home");
  90.     adddir_atroot("incoming");
  91.     adddir_atroot("outgoing");
  92.     adddir_atroot("lost+found");
  93. }
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.